/*
* api地址: https://ims-tech.csot.tcltech.com/api/poros-apis/doc.html
* 注意: get,delete和post,put的函数参数名称不一样
* */
import axios from 'poros/http';

// 分页获取DemoUser测试用户列表
export function getItem(params) {
  return axios({
    url: '/api/dbpm-service/demoUser/list',
    method: 'get',
    params,
  });
}

// 新增DemoUser测试用户
export function postItem(data) {
  return axios({
    url: '/api/dbpm-service/demoUser',
    method: 'post',
    data,
  });
}

// 修改DemoUser测试用户
export function editItem(data) {
  return axios({
    url: '/api/dbpm-service/demoUser',
    method: 'put',
    data,
  });
}

// 删除DemoUser测试用户
export function deleteItem(ids) {
  return axios({
    url: '/api/dbpm-service/demoUser/' + ids,
    method: 'delete',
  });
}

// 导出测试用户
export function exportItem(params) {
  return axios({
    url: '/api/dbpm-service/demoUser/export',
    method: 'get',
    params,
    responseType: 'blob',
  }).then(function(res) {
    // 配置导出excel的文件名
    const filename = decodeURI(
      res.headers['content-disposition'].split(';')[1].split('=')[1]);
    const blob = new Blob([res.data], {
      type: 'application/octet-stream',
    });
    let url = window.URL.createObjectURL(blob);
    let link = document.createElement('a');
    link.style.display = 'none';
    link.href = url;
    link.setAttribute('download', filename);
    document.body.appendChild(link);
    link.click();
  });
}
